package com.yaowk.security;

import com.yaowk.common.api.BaseException;
import com.yaowk.security.api.AuthApi;
import com.yaowk.security.api.model.User;
import com.yaowk.security.utils.ISecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("SecurityAuthController")
@Api(tags = "安全认证")
public class AuthController implements AuthApi {

    @Autowired
    private ISecurityUtils securityUtils;

    @ApiOperation("登录")
    public void login(String username, String password) {

    }

    @ApiOperation("注销")
    public void logout() {

    }

    @GetMapping("/userInfo")
    @ApiOperation("登录用户信息")
    public User userInfo() {
        return securityUtils.getUser();
    }

    @Override
    @ApiOperation("登录用户信息")
    public User userInfo(String token) {
        throw new BaseException("this method not finish");
    }

}
